package sanrenxing.dayEnd.backRepertoryTotal.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sanrenxing.dayEnd.backRepertoryTotal.domain.Financialsecurities;
import sanrenxing.dayEnd.backRepertoryTotal.service.FinancialsecuritiesBiz;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能：证券信息控制器类
 * 编写者：蒋玲苹
 * 日期：
 * 版本：1.0
 */
@RestController
@RequestMapping("/financial")
public class FinancialsecuritiesController {
    @Autowired
    private FinancialsecuritiesBiz financialsecuritiesBiz;
    //显示数据
    @GetMapping("/securities")
    public Map<String,Object> queryAll(int page, int limit, Financialsecurities financialsecurities){
        HashMap<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("count",financialsecuritiesBiz.count(financialsecurities));
        map.put("data",financialsecuritiesBiz.queryAll(financialsecurities,limit,(page-1)*limit));
       map.put("sr",financialsecuritiesBiz.sr());
       map.put("ex",financialsecuritiesBiz.ex());

        return map;
    }

    @PostMapping("/securities")
    public String addSecurities(@RequestBody Financialsecurities financialsecurities){
        //调用方法添加数据
        int rows=financialsecuritiesBiz.add(financialsecurities);
        return rows>0?"add success":"failure";
    }

    //修改数据
    @PutMapping("/securities")
    public String update(@RequestBody Financialsecurities financialsecurities){
        //调用修改数据方法Securities
        int rows=financialsecuritiesBiz.update(financialsecurities);
        return rows>0?"update success":"failure";
    }

    //删除数据
    @DeleteMapping("/securities/{str}")
    public String deleteSecurities(@PathVariable String str){
        int rows=financialsecuritiesBiz.delete(str);
        return rows>0?"success":"failure";
    }
}
